function debounce(fn, tick) {
   let timer = null;

   return function () {
      fn = fn.bind(this)
      if (timer) {
         clearInterval(timer)
      }
      timer = setTimeout(() => {
         fn()
      }, tick)
   }
}